package com.clms.rents.controller;

import com.clms.common.R;
import com.clms.rents.pojo.entity.TbCar;
import com.clms.rents.pojo.vo.Carvo;
import com.clms.rents.service.CarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: clms-third
 * @description: 车辆controller层
 * @author: 杨浩
 * @create: 2021-07-21 16:52
 **/

@RestController
@RequestMapping("rents")
public class CarController {

    @Resource
    private CarService carService;

    @PostMapping("car/{currentPage}/{pageSize}")
   public R selectAllCar(@PathVariable Integer currentPage,
                         @PathVariable Integer pageSize,
                         @RequestBody Carvo carvo){
        return carService.selectAll(currentPage,pageSize,carvo);//
    }

    @PostMapping("insert")
    public R insert(@RequestBody TbCar tbCar){
        return carService.insert(tbCar);
    }

    @GetMapping("selectById/{id}")
    public R selectByid(@PathVariable Integer id){
        return carService.selectById(id);
    }

    @PutMapping("update")
    public R update(@RequestBody TbCar tbCar){
        return carService.update(tbCar);
    }
    @DeleteMapping
    public R delete(@RequestParam Integer id){
        return carService.delete(id);
    }
    @GetMapping("treeSelect")
    public R selectTree(){
        return carService.treeSelect();

    }
}
